//
//  XHF_StyleViewController.m
//  haojia
//
//  Created by 徐宏飞 on 16/4/16.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "XHF_StyleViewController.h"
#import "XHF_BigImageTableViewCell.h"
#import "XHF_SmallTableViewCell.h"
#import "XHF_WorkersTableViewCell.h"

#import "XHF_LbumViewController.h"


@interface XHF_StyleViewController ()<UITableViewDelegate, UITableViewDataSource, XHF_SmallTableViewCellDelegate>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation XHF_StyleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    
    [self.myTableView registerNib:[UINib nibWithNibName:@"XHF_BigImageTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell1"];
    [self.myTableView registerNib:[UINib nibWithNibName:@"XHF_SmallTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell2"];
    [self.myTableView registerNib:[UINib nibWithNibName:@"XHF_WorkersTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell3"];
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 100;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        return 240*WID;
    } else if (indexPath.row == 1){
        return 100*WID;
    } else {
        return 90*WID;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //大图
    if (indexPath.row == 0) {
        
        XHF_BigImageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        return cell;
        
    } else if (indexPath.row == 1) {
        
        XHF_SmallTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        cell.myDelegate = self;
        return cell;
        
    } else {
        XHF_WorkersTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell3"];
        return cell;
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击的是style得第%ld行cell", indexPath.row);
    
    //第一张图片
    if (indexPath.row == 0) {
        //图片浏览器第一个,下标0, 数组为图片数组
        //判断数组是否为空, 判断下标是否超过数组个数
        if (![self getTextArray].count == 0) {
            XHF_LbumViewController *lbumVC = [[XHF_LbumViewController alloc] init];
            lbumVC.imgArr = [self getTextArray];
            lbumVC.currentIndex = 0;
            lbumVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
            [self presentViewController:lbumVC animated:YES completion:nil];
        }
    }
}


#pragma mark - 进入图片浏览器
-(void)presntViewWithIndexPath:(NSIndexPath *)indexPath{
    
    if ([self getTextArray].count == 0 || [self getTextArray].count < indexPath.row + 1) {
        return;
    } else {
        XHF_LbumViewController *lbumVC = [[XHF_LbumViewController alloc] init];
        lbumVC.imgArr = [self getTextArray];
        lbumVC.currentIndex = indexPath.row + 1;
        lbumVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:lbumVC animated:YES completion:nil];
    }
    
}












- (NSMutableArray *)getTextArray{
    NSMutableArray *arr = [NSMutableArray array];
    [arr addObject:@"http://fdfs.xmcdn.com/group16/M09/45/37/wKgDalcPNEWyOojNAAB0leTIQSg301_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group8/M00/45/49/wKgDYVcPZ3qxrxSnAAl9IBG0gU4562_mobile_meduim.png"];
    [arr addObject:@"http://fdfs.xmcdn.com/group11/M0B/12/C9/wKgDa1bmXYLzh8O_AAHl8XBx1gY745_mobile_meduim.png"];
    [arr addObject:@"http://fdfs.xmcdn.com/group7/M04/CB/F5/wKgDWlZuHwzTmnWEAAssMIXlGvs765_mobile_meduim.png"];
    [arr addObject:@"http://fdfs.xmcdn.com/group11/M07/CD/67/wKgDbVZi8wLwDwRiAADcgqAhuoc502_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group8/M00/43/FF/wKgDYVcN6_CTdXmDAATTRsqCusY790_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group16/M04/0B/ED/wKgDbFbOxKPgFUHwAARWc4HMXro869_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group11/M08/30/C9/wKgDa1cHsMGDDp9yAAG2elX_yDs964_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group14/M07/84/FB/wKgDZFYfb6yCFunhAAHdq6TqnLc358_mobile_meduim.jpg"];
    [arr addObject:@"http://fdfs.xmcdn.com/group7/M04/CB/F5/wKgDWlZuHwzTmnWEAAssMIXlGvs765_mobile_meduim.png"];
    [arr addObject:@"http://fdfs.xmcdn.com/group11/M07/CD/67/wKgDbVZi8wLwDwRiAADcgqAhuoc502_mobile_meduim.jpg"];
    
    return arr;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
